//
//  Calculator.m
//  链式语法
//
//  Created by 申元江 on 2018/8/20.
//  Copyright © 2018年 申元江. All rights reserved.
//

#import "Calculator.h"

@implementation Calculator

-(instancetype)init
{
    self = [super init];
    if (self) {
        self.result = 0;
    }
    return self;
}

-(Calculator *(^)(NSInteger num))add
{
    return ^id(NSInteger num){
        self.result += num;
        return self;
    };
}

-(Calculator *(^)(NSInteger))mins
{
    return ^id(NSInteger num){
        self.result -= num;
        return self;
    };
}

-(Calculator *(^)(NSInteger))multiply
{
    return ^id(NSInteger num){
        self.result *= num;
        return self;
    };
}

-(Calculator *(^)(NSInteger))divide
{
    return ^id(NSInteger num){
        NSAssert(num !=0, @"除数不能为零");
        self.result /= num;
        return self;
    };
}
























@end
